package com.newcapec.news.servlet;

import com.newcapec.news.dao.SysUserDao;
import com.newcapec.news.dao.impl.SysUserDaoImpl;
import com.newcapec.news.entity.SysUser;
import com.newcapec.news.util.MD5Util;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Description: 添加用户信息
 * @Author: fujun
 * @Date : 2022/3/17 16:17
 * @Version : 1.0
 * @company 新开普电子股份有限公司
 */
@WebServlet("/updateUser")
public class UpdateSysUserServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        req.setCharacterEncoding("utf-8");
//        resp.setCharacterEncoding("utf-8");



         String  name=req.getParameter("userName");
         String  pwd=req.getParameter("userPwd");
         String  uid=req.getParameter("uid");

         SysUserDao sysUserDao =new SysUserDaoImpl();

        SysUser sysUser=new SysUser();


        sysUser.setId(Integer.parseInt(uid));
        sysUser.setName(name);
        sysUser.setPwd(MD5Util.toMD5(pwd));
        sysUserDao.updateUser(sysUser);
        resp.sendRedirect("page/AccountManagement.html");




    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
